﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ARS.PublicTool.WebHelper.WebPage
{
    public class MessageBox
    {
        /// <summary>
        /// 显示消息提示对话框
        /// </summary>
        /// <param name="page">当前页面指针，一般为this</param>
        /// <param name="msg">提示信息</param>
        public static void Show(System.Web.UI.Page page, string msg, string title = "提示")
        {
            page.ClientScript.RegisterStartupScript(page.GetType(), "message", "<script language='javascript' defer>$(function() {myPrompt.showConfirm({message:'" + msg + "',title:'" + title + "'});});</script>");
        }

        /// <summary>
        /// 控件点击 消息确认提示框
        /// </summary>
        /// <param name="page">当前页面指针，一般为this</param>
        /// <param name="msg">提示信息</param>
        public static void ShowConfirm(System.Web.UI.Page page, string msg, string scriptStr = "", string title = "提示")
        {
            page.ClientScript.RegisterStartupScript(page.GetType(), "message", "<script language='javascript' defer>$(function() {myPrompt.showConfirm({message:'" + msg + "',title:'" + title + "',buttons: {\"确定\": function() {" + scriptStr + ";$(this).dialog(\"close\");}, \"取消\": function() {$(this).dialog(\"close\");}}});});</script>");
        }


        /// <summary>
        /// 显示信息
        /// </summary>
        public static void ShowInfo(System.Web.UI.Page page,string title, string content, int autoClose=0)
        {
            string closeStr=null;
            if (autoClose > 0)
            {
                closeStr = "autoClose: " + autoClose;
            }
            string info = string.Format("<script language='javascript'>easyDialog.open({container: {header : {0},content:{1}},{2}});</script>", title, content, closeStr);
            page.ClientScript.RegisterStartupScript(page.GetType(), "", info);

        }


    }
}
